package com.fy.common.model.im;


/**
 * 通过net的Channel 可获取如下附属字段
 * Attribute<AttributeChannelModel> attr = channelHandlerContext.channel().attr(SocketServerBusiHandler.NETTY_CHANNEL_KEY);
 * AttributeChannelModel attributeChannelModel = attr.get();
 */
public class AttributeChannelModel {

    //chanle附属信息
    private Long userId;
    private Integer protocolType;
    private Integer deviceType;
    private String deviceCode;
    private String channelKey;

    private String tenantId; //商户id

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public Integer getProtocolType() {
        return protocolType;
    }

    public void setProtocolType(Integer protocolType) {
        this.protocolType = protocolType;
    }

    public Integer getDeviceType() {
        return deviceType;
    }

    public void setDeviceType(Integer deviceType) {
        this.deviceType = deviceType;
    }


    public String getChannelKey() {
        return channelKey;
    }

    public void setChannelKey(String channelKey) {
        this.channelKey = channelKey;
    }

    public String getDeviceCode() {
        return deviceCode;
    }

    public void setDeviceCode(String deviceCode) {
        this.deviceCode = deviceCode;
    }


    public String getTenantId() {
        return tenantId;
    }

    public void setTenantId(String tenantId) {
        this.tenantId = tenantId;
    }

    //channelkey 按此规则存入key-> tenantId_userId_protocolType_deviceCode
    public String createChannelKey(AttributeChannelModel attributeChannelModel){
        this.channelKey = attributeChannelModel.getTenantId() + "_" +  attributeChannelModel.getUserId() + "_" + attributeChannelModel.getProtocolType() + "_" + attributeChannelModel.getDeviceCode();
        return channelKey;

    }
}
